using System.Reflection;
using Microsoft.EntityFrameworkCore;

namespace Ef_Core_learn;

public class MyContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }
    public DbSet<Post> Posts { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
       
        // optionsBuilder.UseMySql("""
        //                         server=localhost;
        //                         port=3306;
        //                         user=root;
        //                         password=rootroot;
        //                         database=efcore-learn_test
        //                         """,
        //     ServerVersion.Parse("8.4.3-mysql"));

        optionsBuilder.UseSqlite("""
                                 Data Source=C:\Users\18103\RiderProjects\chengheng-net\Ef-Core-learn\efcore-learn_test.db
                                 """);
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // modelBuilder.Entity<Blog>(builder =>
        // {
        //     builder.HasMany(e => e.Posts)
        //         .WithOne(e => e.Blog)
        //         .HasForeignKey("blodid_fengliulin")
        //         .IsRequired(false);
        // });
        
    }

    public void Test()
    {
        
    }
}